package cn.ad.server.persistence.dao;

import java.util.List;

import cn.ad.server.domain.ad.AdSize;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;

@Component
public interface AdSizeDao {
	
	
	@Results(value = { 
			@Result(column = "id", property = "id", id=true),
			@Result(column = "create_time", property = "createTime"),
			@Result(column = "update_time", property = "updateTime") })
	@Select("select * from ad_size")
	List<AdSize> findAll();
	
	@Results(value = { 
			@Result(column = "id", property = "id", id=true),
			@Result(column = "create_time", property = "createTime"),
			@Result(column = "update_time", property = "updateTime") })
	@Select("select * from ad_size where update_time >= #{value}")
	List<AdSize> findAfterTime(String warmUpTime);

	@Results(value = { 
			@Result(column = "id", property = "id", id=true),
			@Result(column = "create_time", property = "createTime"),
			@Result(column = "update_time", property = "updateTime") })
	@Select("select * from ad_size where id = #{value}")
	AdSize findById(int id);
	
	@Results(value = { 
			@Result(column = "id", property = "id", id=true),
			@Result(column = "create_time", property = "createTime"),
			@Result(column = "update_time", property = "updateTime") })
	@Select("select * from ad_size where id = #{id} and status = #{status}")
	AdSize selectById(@Param("id")long id, @Param("status")int status);
	
	@Results(value = { 
			@Result(column = "id", property = "id", id=true),
			@Result(column = "create_time", property = "createTime"),
			@Result(column = "update_time", property = "updateTime") })
	@Select("select * from ad_size where id = #{id} and status = 1")
	AdSize findValidById(@Param("id")long id);

}
